package com.example.itshome.activity;

import android.view.View;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import com.example.itshome.R;
import com.example.itshome.network.AbstractNetworkRequest;
import com.example.itshome.network.ChangePasswordRequest;

public class ChangePasswordActivity extends AppCompatActivity {

    private ImageView backImageView;
    private EditText oldPasswordEditText;
    private EditText newPasswordEditText;
    private EditText newPasswordConfirmEditText;
    private TextView confirmTextView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_change_password);
        initFind();
        initButton();
    }

    private void initFind(){
        backImageView=findViewById(R.id.imv_change_password_page_back);
        confirmTextView=findViewById(R.id.txv_change_password_page_confirm);
        oldPasswordEditText=findViewById(R.id.edt_change_password_page_old_password);
        newPasswordEditText=findViewById(R.id.edt_change_password_page_new_password);
        newPasswordConfirmEditText=findViewById(R.id.edt_change_password_page_new_password_confirm);
    }

    private void initButton(){
        backImageView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                finish();
            }
        });
        confirmTextView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                AbstractNetworkRequest request=new ChangePasswordRequest(ChangePasswordActivity.this)
                        .setOldPassword(oldPasswordEditText.getText().toString())
                        .setNewPassword(newPasswordEditText.getText().toString())
                        .setNewPasswordConfirm(newPasswordConfirmEditText.getText().toString());
                request.start();
            }
        });
    }
}